package com.jshan.blog.base.admin.dto;

import com.jshan.blog.valid.LoginAndRegisterGroupValid;
import com.jshan.blog.valid.UpdateGroupValid;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

@Data
@Schema(description = "登录注册 dto")
public class LoginAndRegisterDto {

    @Schema(description = "用户名")
    @NotBlank(message = "用户名不能为空！", groups = {LoginAndRegisterGroupValid.class})
    private String username;

    @NotBlank(message = "密码不能为空！", groups = {LoginAndRegisterGroupValid.class})
    @Schema(description = "密码")
    private String pwd;

    @Schema(description = "昵称")
    private String nickname;

    @Schema(description = "手机号")
    @Pattern(regexp = "0?(13|14|15|18|17)[0-9]{9}",
            message = "手机号码格式不正确",
            groups = {UpdateGroupValid.class})
    private String phone;

    @Pattern(regexp = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}",
            message = "邮箱格式不正确",
            groups = {UpdateGroupValid.class})
    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "性别")
    private String sex;

    @NotBlank(message = "验证码不能为空", groups = {UpdateGroupValid.class, LoginAndRegisterGroupValid.class})
    @Schema(description = "验证码")
    private String code;

}
